using Slaks.DocumentSerialization.Document;
using Slaks.Graphs;
using Slaks.Graphs.GraphBuilder;
using Slaks.Graphs.GraphBuilder.Schenker;
using Slaks.Graphs.GraphBuilder.Slaks;

namespace Slaks.Analysis.Mediators
{
	public class GraphBuilderMediator
	{
		public static void AddRepresentation()
		{
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.StandardRepresentationSchenker, new StandardRepresentationSchenker());
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.SimpleRepresentationSchenker, new SimpleRepresentationSchenker());
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.NDistanceRepresentationSchenker, new NDistanceRepresentationSchenker());
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.NSimpleDistanceRepresentationSchenker, new NSimpleDistanceRepresentationSchenker());
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.RawFrequencyRepresentationSchenker, new RawFrequencyRepresentationSchenker());
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.NormalizedFrequencyRepresentationSchenker, new NormalizedFrequencyRepresentationSchenker());

			//slaks representation
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.StandardRepresentationSlaks, new StandardRepresentationSlaks());
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.SimpleRepresentationSlaks, new SimpleRepresentationSlaks());
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.NDistanceRepresentationSlaks, new NDistanceRepresentationSlaks());
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.NSimpleDistanceRepresentationSlaks, new NSimpleDistanceRepresentationSlaks());
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.RawFrequencyRepresentationSlaks, new RawFrequencyRepresentationSlaks());
			GraphBuilderFactory.Instance.AddGraphBuilder(BuilderType.NormalizedFrequencyRepresentationSlaks, new NormalizedFrequencyRepresentationSlaks());
		}

		public static Graph BuildAdaptor(Document document, IRepresentation representation, BuilderType builderType, int graphSize, int distanceValue)
		{
			Graph graph = null;

			if (builderType == BuilderType.NDistanceRepresentationSchenker ||
				builderType == BuilderType.NDistanceRepresentationSlaks ||
				builderType == BuilderType.NSimpleDistanceRepresentationSchenker ||
				builderType == BuilderType.NSimpleDistanceRepresentationSlaks
				)
				graph = representation.Build(document, graphSize, distanceValue);
			else graph = representation.Build(document, graphSize);

			return graph;
		}
	}
}